package com.unicom.office.unit;

import com.unicom.office.node.OfficeCellStype;

public class CellUnit extends OfficeUnit {
    public OfficeCellStype cellStype;

    public String getText(){
        String result = "";
        for (OfficeUnit child : children) {
            if(child instanceof ParagraphUnit) {
                result += ((ParagraphUnit)child).getText();
            }
        }
        return result;
    }

    public Boolean isNumeric() {
        if(children.size() != 1) return false;
        if(children.get(0).children.size() != 1) return false;
        OfficeUnit first = children.get(0).children.get(0);
        if(first instanceof TextRangeUnit) {
            return ((TextRangeUnit)first).getIsNumeric();
        }else{
            return false;
        }
    }

    public String toString(){
        return getText();
    }

    protected boolean testChildType(OfficeUnit child) {
        return child instanceof ParagraphUnit;
    }
}
